
/**
 * AppleIIGo
 * GCR 5&3 Disk Image class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "GCRDiskImage.h"

#ifndef GCR53DISKIMAGE_H
#define GCR53DISKIMAGE_H

#define GCR53_SECTOR_BYTENUM	0x100
#define GCR53_TRACK_SECTORNUM	0xd
#define GCR53_TRACK_BYTENUM		(GCR53_TRACK_SECTORNUM * GCR53_SECTOR_BYTENUM)

class GCR53DiskImage : public GCRDiskImage {
public:
	static bool isDiskImageValid(UINT32 diskType, UINT32 diskImageByteNum);
	
	GCR53DiskImage(char * diskImagePath,
				   UINT32 diskImageOffset,
				   UINT32 diskImageByteNum,
				   UINT8 gcrVolume,
				   bool isWriteProtectionForced);
	~GCR53DiskImage();
	
protected:
	void getDiskTrack(UINT32 * trackIndex, UINT32 * headIndex, 
					  UINT32 * diskImageTrackByteNum,
					  UINT32 diskImageTrackIndex);
	void getDiskImageTrack(UINT32 * diskImageTrackIndex,
						   UINT32 * diskImageTrackByteNum,
						   UINT32 trackIndex, UINT32 headIndex);
	
	void writeAddressField(UINT32 diskImageTrackIndex, UINT32 sectorIndex);
	void writeDataField(UINT8 * sectorData);
	void writeTrack(UINT32 diskImageTrackIndex, UINT8 * diskImageTrackData);
	
	bool readAddressField(UINT32 diskImageTrackIndex,
						  UINT32 sectorIndex);
	bool readDataField(UINT8 * sectorData);
	bool readTrack(UINT32 diskImageTrackIndex, UINT8 * diskImageTrackData);
	
private:
	UINT32 diskImageOffset;
	
	UINT32 diskImageTrackNum;
	UINT8 gcrVolume;
};

#endif
